package com.jaws.core.common.xxljob.annotation;


import com.jaws.core.common.enums.JawsJobBlockStrategyEnum;
import com.jaws.core.common.enums.JawsJobFailStrategyEnum;
import com.jaws.core.common.enums.JawsJobRouteStrategyEnum;
import org.springframework.context.annotation.Import;

import org.springframework.stereotype.Component;

import javax.annotation.Nullable;
import javax.validation.constraints.Size;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * jaws 自定义JOB注解
 *
 * @author liangqm
 * @date 2018-07-15 12:54:18
 * @since v1.0.3
 */
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Component
@Import(JawsJobHandlerRegistrar.class)
public @interface JawsJobHandler {

	/**
	 * job 名称,默认:所在class 全名
	 */
	@Nullable
	@Size(max = 255)
	String jobName() default "";

	@Size(max = 255)
	String jobDesc() default "jobDesc";

	/**
	 * 执行方法,默认execute; 参数:String.class ,返回类型:com.xxl.job.core.biz.model.ReturnT
	 */
	@Size(max = 255)
	String jobMethod() default "execute";

	/**
	 * job cron 表达式
	 */
	@Nullable
	@Size(max = 128)
	String jobCron();

	/**
	 * 路由策略,默认:第一个
	 */
	JawsJobRouteStrategyEnum routeStrategy() default JawsJobRouteStrategyEnum.FIRST;

	/**
	 * 阻塞处理策略,默认:单机串行
	 */
	JawsJobBlockStrategyEnum blockStrategy() default JawsJobBlockStrategyEnum.SERIAL_EXECUTION;

	/**
	 * 失败测，默认:警告
	 */
	JawsJobFailStrategyEnum failStrategy() default JawsJobFailStrategyEnum.FAIL_ALARM;

}
